package com.hangjiang.gulidear.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

/**
 * Configitem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "configitem", catalog = "sqm")
public class ConfigItem extends BaseEntity {

	// Fields

	private String configId;
	private Project project;
	private ConfigType configtype;
	private User user;
	private String configName;
	private String configIdent;
	private Date configTime;
	private String attachPath;
	private Integer securityClassify;
	private double version;
	private Integer isDelete;
	private Set<BaseLine> baselines = new HashSet<BaseLine>(0);
	private Set<ConfigIssue> configissues = new HashSet<ConfigIssue>(0);
	private Set<ConfigChange> configchanges = new HashSet<ConfigChange>(0);

	// Constructors

	/** default constructor */
	public ConfigItem() {
	}

	/** full constructor */
	public ConfigItem(Project project, ConfigType configtype, User user,
			String configName, String configIdent, Date configTime,
			String attachPath, Integer securityClassify, double version,
			Integer isDelete) {
		this.project = project;
		this.configtype = configtype;
		this.user = user;
		this.configName = configName;
		this.configIdent = configIdent;
		this.configTime = configTime;
		this.attachPath = attachPath;
		this.securityClassify = securityClassify;
		this.version = version;
		this.isDelete = isDelete;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "configId", unique = true, nullable = false, length = 32)
	public String getConfigId() {
		return this.configId;
	}

	public void setConfigId(String configId) {
		this.configId = configId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "projId")
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "typeId")
	public ConfigType getConfigtype() {
		return this.configtype;
	}

	public void setConfigtype(ConfigType configtype) {
		this.configtype = configtype;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "configName", length = 50)
	public String getConfigName() {
		return this.configName;
	}

	public void setConfigName(String configName) {
		this.configName = configName;
	}

	@Column(name = "configIdent", length = 30)
	public String getConfigIdent() {
		return this.configIdent;
	}

	public void setConfigIdent(String configIdent) {
		this.configIdent = configIdent;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "configTime", length = 0)
	public Date getConfigTime() {
		return this.configTime;
	}

	public void setConfigTime(Date configTime) {
		this.configTime = configTime;
	}

	@Column(name = "attachPath", length = 200)
	public String getAttachPath() {
		return this.attachPath;
	}

	public void setAttachPath(String attachPath) {
		this.attachPath = attachPath;
	}

	@Column(name = "securityClassify")
	public Integer getSecurityClassify() {
		return this.securityClassify;
	}

	public void setSecurityClassify(Integer securityClassify) {
		this.securityClassify = securityClassify;
	}

	@Column(name = "version", precision = 5 ,scale = 3)
	public double getVersion() {
		return this.version;
	}

	public void setVersion(double version) {
		this.version = version;
	}

	@Column(name = "isDelete")
	public Integer getIsDelete() {
		return this.isDelete;
	}

	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "configbaseline", catalog = "sqm", joinColumns = { @JoinColumn(name = "configId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "bLineId", nullable = false, updatable = false) })
	public Set<BaseLine> getBaselines() {
		return this.baselines;
	}

	public void setBaselines(Set<BaseLine> baselines) {
		this.baselines = baselines;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "configitem")
	public Set<ConfigIssue> getConfigissues() {
		return this.configissues;
	}

	public void setConfigissues(Set<ConfigIssue> configissues) {
		this.configissues = configissues;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "configItem")
	public Set<ConfigChange> getConfigchanges() {
		return this.configchanges;
	}

	public void setConfigchanges(Set<ConfigChange> configchanges) {
		this.configchanges = configchanges;
	}

}